<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var findKthLargest = function (nums, k) {
      nums.sort((a, b) => b - a) //降序排序
      for (var i = 0; i < nums.length; i++) {
        if ((k - 1) == i) {//i从0开始
          return nums[i]
        }
      }
    };
    console.log(findKthLargest(nums = ["2", "21", "12", "1"], k = 3)) 
  </script>
</body>

</html>